package com.nthink.indicators.controller;

import com.nthink.indicators.pojo.operationindex.workload.WorkloadYear;
import com.nthink.indicators.pojo.pie.PieDataModel;
import com.nthink.indicators.pojo.qualitymanagement.BaseIndex;
import com.nthink.indicators.pojo.qualitymanagement.ClinicalPathway;
import com.nthink.indicators.pojo.qualitymanagement.DrugManagement;
import com.nthink.indicators.pojo.qualitymanagement.SafeManagement;
import com.nthink.indicators.service.qualitymanagement.BaseIndexService;
import com.nthink.indicators.service.qualitymanagement.ClinicalPathwayService;
import com.nthink.indicators.service.qualitymanagement.DrugManagementService;
import com.nthink.indicators.service.qualitymanagement.SafeManagementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * @author Angus Yu
 * @date 2021-03-31 16:23
 */
@Api(tags = "质量管理指标")
@RestController
public class QualityManagementController {

    @Autowired
    private BaseIndexService baseIndexService;

    @Autowired
    private SafeManagementService safeManagementService;

    @Autowired
    private ClinicalPathwayService clinicalPathwayService;

    @Autowired
    private DrugManagementService drugManagementService;

    @ApiOperation("基本监测指标（医务科）")
    @GetMapping("/getBaseIndex")
    public BaseIndex getBaseIndex(@RequestParam(required = false) Date startTime, @RequestParam(required = false) Date endTime) {
        BaseIndex baseIndex = baseIndexService.getBaseIndex(startTime, endTime);
        return baseIndex;
    }

    @ApiOperation("患者安全管理（医务科）")
    @GetMapping("/getSafeManagement")
    public SafeManagement getSafeManagement(@RequestParam(required = false) Date startTime, @RequestParam(required = false) Date endTime) {
        SafeManagement safeManagement = safeManagementService.getSafeManagement(startTime, endTime);
        return safeManagement;
    }

    @ApiOperation("临床路径管理（医务科）")
    @GetMapping("/getClinicalPathway")
    public ClinicalPathway getClinicalPathway(@RequestParam(required = false) Date startTime, @RequestParam(required = false) Date endTime) {
        ClinicalPathway clinicalPathway = clinicalPathwayService.getClinicalPathway(startTime, endTime);
        return clinicalPathway;
    }

    @ApiOperation("各病种临床路径入组例数")
    @GetMapping("/getDiagnosisInfo")
    public List<PieDataModel> getDiagnosisInfo(@RequestParam(required = false) Date startTime, @RequestParam(required = false) Date endTime) {
        return clinicalPathwayService.getDiagnosisInfo(startTime, endTime);
    }

    @ApiOperation("临床路径各组比率")
    @GetMapping("/getCateInfo")
    public List<PieDataModel> getCateInfo(@RequestParam(required = false) Date startTime, @RequestParam(required = false) Date endTime) {
        return clinicalPathwayService.getCateInfo(startTime, endTime);
    }
    @ApiOperation("药事管理监测")
    @GetMapping("/getDrugManagement")
    public DrugManagement getDrugManagement(@RequestParam(required = false) Date startTime, @RequestParam(required = false) Date endTime) {
        return drugManagementService.getDrugManagement(startTime, endTime);
    }
}
